/* USER CODE BEGIN Header */
/**
 ******************************************************************************
 * @file           : main.c
 * @brief          : Main program body
 ******************************************************************************
 * @attention
 *
 * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
 * All rights reserved.</center></h2>
 *
 * This software component is licensed by ST under BSD 3-Clause license,
 * the "License"; You may not use this file except in compliance with the
 * License. You may obtain a copy of the License at:
 *                        opensource.org/licenses/BSD-3-Clause
 *
 ******************************************************************************
 */
/* USER CODE END Header */

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "ssd2828.h"
//#include "R69434.h"
//#include "ST7796S__PH035NA_01B.h"
#include "ST7703__BV055HDE_N47_3Q00.h"

/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */

/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/
UART_HandleTypeDef huart1;

/* USER CODE BEGIN PV */

/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART1_UART_Init(void);
static void MX_NVIC_Init(void);
/* USER CODE BEGIN PFP */

/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */

int _write(int file, char *ptr, int len)
{
	switch (file) {
	case STDOUT_FILENO: // stdout
		HAL_UART_Transmit(&huart1, (uint8_t *)ptr, len, 0xff);
		break;
	case STDERR_FILENO: // stderr
		// Send the string somewhere
		break;
	default:
		return -1;
	}
	return len;
}

void init(void)
{
	// SSD2828_Initial
	W_C(0xb7);
	W_D(0x50); // 50=TX_CLK 70=PCLK
	W_D(0x00); // Configuration Register

	W_C(0xb8);
	W_D(0x00);
	W_D(0x00); // VC(Virtual ChannelID) Control Register

	W_C(0xb9);
	W_D(0x00); // 1=PLL disable
	W_D(0x00);
	// TX_CLK/MS should be between 5Mhz to100Mhz
	W_C(0xBA); // PLL=(TX_CLK/MS)*NS 8228=480M 4428=240M  061E=120M
		   // 4214=240M 821E=360M 8219=300M
	W_D(0x14); // D7-0=NS(0x01 : NS=1)
	W_D(0x42); // D15-14=PLL范围 00=62.5-125 01=126-250 10=251-500
		   // 11=501-1000  DB12-8=MS(01:MS=1)

	W_C(0xBB); // LP Clock Divider LP clock = 400MHz / LPD / 8 = 240 / 8 / 4
		   // = 7.5MHz
	W_D(0x03); // D5-0=LPD=0x1 – Divide by 2
	W_D(0x00);

	W_C(0xb9);
	W_D(0x01); // 1=PLL disable
	W_D(0x00);
	// MIPI lane configuration
	W_C(0xDE); //通道数
	W_D(0x02); // 11=4LANE 10=3LANE 01=2LANE 00=1LANE
	W_D(0x00);

	W_C(0xc9);
	W_D(0x02);
	W_D(0x23); // p1: HS-Data-zero  p2: HS-Data- prepare  --> 8031 issue
	delay_ms(100);

	/*============================================================================*/

	// LCD driver initialization
	W_C(0xB7);
	W_D(0x50); // 10=TX_CLK 30=PCLK
	W_D(0x00);

	W_C(0xBD);
	W_D(0x00);
	W_D(0x00);

	/*============================================================================*/

	////////////////////////$################################
	// Set EXTC,
	GP_COMMAD_PA(0x04);
	W_D(0xB9);
	W_D(0xFF);
	W_D(0x83);
	W_D(0x89);
	//******************************** 3-Power Mode
	//******************************
	// VSP=5.5V; VSN=-5.5V; VDD1=1.8V
	// VGH=15.2V, VGL= -12V,
	// VSPR=5V, VSNR=-5V
	// Set Power
	// GP_COMMAD_PA(0x11);
	// W_D(0xB1);W_D(0x7F);W_D(0x14);W_D(0x14);W_D(0x31);W_D(0x51);W_D(0x50);W_D(0xD0);W_D(0xEC);W_D(0x9C);W_D(0x80);W_D(0x20);W_D(0x20);W_D(0xF8);W_D(0xAA);W_D(0xAA);W_D(0xA3);
	//******************************** ICP Mode
	//******************************
	// Internal Charge Pump Mode
	// VGH=15.2V, VGL= -12V,
	// VSPR=5V, VSNR=-5V
	// Set Power,
	// XDK(VSP) X2 Pump
	// XDKN(VSN) X2.5 Pump
	// VGH source: 2VSP-VSN
	// VGL source: 2VSN-VSP
	GP_COMMAD_PA(0x15);
	W_D(0xB1);
	W_D(0x7f);
	W_D(0x10);
	W_D(0x10);
	W_D(0xF2);
	W_D(0x32);
	W_D(0x90);
	W_D(0x10);
	W_D(0xf2);
	W_D(0x96);
	W_D(0x80);
	W_D(0x20);
	W_D(0x20);
	W_D(0xF8);
	W_D(0xaa);
	W_D(0xaa);
	W_D(0xa0);
	W_D(0x00);
	W_D(0x80);
	W_D(0x30);
	W_D(0x00);

	// Set Display. Column Inversion
	GP_COMMAD_PA(0x0B);
	W_D(0xB2);
	W_D(0x80);
	W_D(0x50);
	W_D(0x05);
	W_D(0x03);
	W_D(0x50);
	W_D(0x38);
	W_D(0x11);
	W_D(0x64);
	W_D(0x55);
	W_D(0x09);
	// Set GIP1
	GP_COMMAD_PA(0x0C);
	W_D(0xB4);
	W_D(0x77);
	W_D(0x5E);
	W_D(0x77);
	W_D(0x5E);
	W_D(0x77);
	W_D(0x5E);
	W_D(0x0E);
	W_D(0x72);
	W_D(0x0E);
	W_D(0x72);
	W_D(0x8E);

	// Set GIP2
	GP_COMMAD_PA(0x24);
	W_D(0xD3);
	W_D(0x00);
	W_D(0x00);
	W_D(0x00);
	W_D(0x00);
	W_D(0x00);
	W_D(0x08);
	W_D(0x08);
	W_D(0x32);
	W_D(0x10);
	W_D(0x00);
	W_D(0x00);
	W_D(0x00);
	W_D(0x03);
	W_D(0xCA);
	W_D(0x03);
	W_D(0xCA);
	W_D(0x00);
	W_D(0x00);
	W_D(0x00);
	W_D(0x00);
	W_D(0x27);
	W_D(0x22);
	W_D(0x01);
	W_D(0x01);
	W_D(0x23);
	W_D(0x00);
	W_D(0x00);
	W_D(0x00);
	W_D(0x05);
	W_D(0x08);
	W_D(0x00);
	W_D(0x00);
	W_D(0x0A);
	W_D(0x00);
	W_D(0x01);
	// Set GIP3 Forward
	GP_COMMAD_PA(0x27);
	W_D(0xD5);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x01);
	W_D(0x00);
	W_D(0x03);
	W_D(0x02);
	W_D(0x19);
	W_D(0x19);
	W_D(0x19);
	W_D(0x19);
	W_D(0x21);
	W_D(0x20);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	// Set GIP3 Backward
	GP_COMMAD_PA(0x27);
	W_D(0xD6);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x02);
	W_D(0x03);
	W_D(0x00);
	W_D(0x01);
	W_D(0x19);
	W_D(0x19);
	W_D(0x18);
	W_D(0x18);
	W_D(0x20);
	W_D(0x21);
	W_D(0x19);
	W_D(0x19);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	W_D(0x18);
	// Set GAMMA
	GP_COMMAD_PA(0x2B);
	W_D(0xE0);
	W_D(0x05);
	W_D(0x0A);
	W_D(0x0B);
	W_D(0x24);
	W_D(0x2D);
	W_D(0x3F);
	W_D(0x11);
	W_D(0x34);
	W_D(0x04);
	W_D(0x08);
	W_D(0x0B);
	W_D(0x17);
	W_D(0x0E);
	W_D(0x11);
	W_D(0x14);
	W_D(0x13);
	W_D(0x14);
	W_D(0x0B);
	W_D(0x12);
	W_D(0x17);
	W_D(0x18);
	W_D(0x05);
	W_D(0x0A);
	W_D(0x0B);
	W_D(0x24);
	W_D(0x2D);
	W_D(0x3F);
	W_D(0x11);
	W_D(0x34);
	W_D(0x04);
	W_D(0x08);
	W_D(0x0B);
	W_D(0x17);
	W_D(0x0E);
	W_D(0x11);
	W_D(0x14);
	W_D(0x13);
	W_D(0x14);
	W_D(0x0B);
	W_D(0x12);
	W_D(0x17);
	W_D(0x18);
	// Set VCOM
	GP_COMMAD_PA(0x03);
	W_D(0xB6);
	W_D(0x44);
	W_D(0x44);
	// Set VP_REF=5V , VN_REF=-5V
	GP_COMMAD_PA(0x02);
	W_D(0xD2);
	W_D(0x77);
	// Set Display Direction
	GP_COMMAD_PA(0x02);
	W_D(0xCC);
	W_D(0x02);
	// Set TCON
	GP_COMMAD_PA(0x05);
	W_D(0xC7);
	W_D(0x00);
	W_D(0x80);
	W_D(0x60);
	W_D(0xC0);

	// Sleep Out
	GP_COMMAD_PA(0x02);
	W_D(0x11);
	W_D(0x00);
	delay_ms(150);
	// Display On
	GP_COMMAD_PA(0x02);
	W_D(0x29);
	W_D(0x00);
	delay_ms(20);

	//////////////////////////

	/****************************************** SSD2825_Initial
	 * ***************************************************************/

	// SSD2828_Initial

	W_C(0xB7);
	W_D(0x50);
	W_D(0x00); // Configuration Register

	W_C(0xB8);
	W_D(0x00);
	W_D(0x00); // VC(Virtual ChannelID) Control Register

	W_C(0xB9);
	W_D(0x00); // 1=PLL disable
	W_D(0x00);

	W_C(0xBA); // PLL=(TX_CLK/MS)*NS 8228=480M 4428=240M  061E=120M
		   // 4214=240M 821E=360M 8219=300M 8225=444M 8224=432
	W_D(0x28); // D7-0=NS(0x01 : NS=1)
	W_D(0x82); // D15-14=PLL范围 00=62.5-125 01=126-250 10=251-500
		   // 11=501-1000  DB12-8=MS(01:MS=1)

	W_C(0xBB); // LP Clock Divider LP clock = 400MHz / LPD / 8 = 480 / 8/ 8
		   // = 7MHz
	W_D(0x06); // D5-0=LPD=0x1 – Divide by 2
	W_D(0x00);

	W_C(0xB9);
	W_D(0x01); // 1=PLL disable
	W_D(0x00);

	/*W_C(0xC9);
	W_D(0x02);
	W_D(0x23); // p1: HS-Data-zero  p2: HS-Data- prepare  --> 8031 issue
	delay_ms(100);

	W_C(0xCA);
	W_D(0x01); // CLK Prepare
	W_D(0x23); // Clk Zero

	W_C(0xCB); // local_write_reg(addr=0xCB,data=0x0510)
	W_D(0x10); // Clk Post
	W_D(0x05); // Clk Per

	W_C(0xCC); // local_write_reg(addr=0xCC,data=0x100A)
	W_D(0x05); // HS Trail
	W_D(0x10); // Clk Trail*/

	W_C(0xD0);
	W_D(0x00);
	W_D(0x00);

	// RGB interface configuration
	W_C(0xB1);
	W_D(HSPW); // HSPW 07
	W_D(VSPW); // VSPW 05

	W_C(0xB2);
	W_D(HBPD); // HBPD 0x64=100
	W_D(VBPD); // VBPD 8 减小下移

	W_C(0xB3);
	W_D(HFPD - 1); // HFPD 8
	W_D(VFPD - 1); // VFPD 10

	W_C(0xB4); // Horizontal active period 720=02D0
	W_D(0x1c); // 013F=319 02D0=720
	W_D(0x02); // HACT=0x01E0=480	,0x021c=540

	W_C(0xB5); // Vertical active period 1280=0500
	W_D(0xc0); // 01DF=479 0500=1280
	W_D(0x03); // VACT=0x0320=800	,0x03c0=960	 ,0x0356=854

	W_C(0xB6); // RGB CLK  16BPP=00 18BPP=01
	W_D(0x07); // D7=0 D6=0 D5=0  D1-0=11 – 24bpp
	W_D(0x20); // D15=VS D14=HS D13=CLK D12-9=NC D8=0=Video with blanking
		   // packet. 00-F0

	// MIPI lane configuration
	W_C(0xDE); //通道数
	W_D(0x01); // 11=4LANE 10=3LANE 01=2LANE 00=1LANE
	W_D(0x00);

	W_C(0xD6); //  05=BGR  04=RGB
	W_D(0x05); // D0=0=RGB 1:BGR D1=1=Most significant byte sent first
	W_D(0x00);

	W_C(0xB7);
	W_D(0x4B);
	W_D(0x02);

	W_C(0x2C);
	// W_C(0x3C);
}

/* USER CODE END 0 */

/**
 * @brief  The application entry point.
 * @retval int
 */
int main(void)
{
	/* USER CODE BEGIN 1 */

	/* USER CODE END 1 */

	/* MCU
	 * Configuration--------------------------------------------------------*/

	/* Reset of all peripherals, Initializes the Flash interface and the
	 * Systick. */
	HAL_Init();

	/* USER CODE BEGIN Init */

	/* USER CODE END Init */

	/* Configure the system clock */
	SystemClock_Config();

	/* USER CODE BEGIN SysInit */

	/* USER CODE END SysInit */

	/* Initialize all configured peripherals */
	MX_GPIO_Init();
	MX_USART1_UART_Init();

	/* Initialize interrupts */
	MX_NVIC_Init();
	/* USER CODE BEGIN 2 */

	/* USER CODE END 2 */

	/* Infinite loop */
	/* USER CODE BEGIN WHILE */
	printf("Program Start\r\n");

	// test spi
	/*spi_init();
	while(1)
	{
	  spi_write(SPI_CMD, 0xa5);
	  HAL_Delay(10);
	  spi_write(SPI_DAT, 0x5a);
	  HAL_Delay(10);
	}*/

	spi_init();

	ssd2828_hwreset();

	/*ssd2828_writeReg(0xd4, 0x00, 0xfa);

	uint16_t ssd2828ID = ssd2828_readReg(0xb0);
	


	printf("read 2828 id = 0x%x\r\n", ssd2828ID);*/

	/*for(uint8_t i = 0xB0; i < 0xff; i++)
	{
	  uint16_t regData = ssd2828_readReg(i);

	  printf("reg(0x%02x) = 0x%04x \r\n", i, regData);
	}*/
	// readMipi()

	// Init_SSD2828(init_ST7703__BV055HDE_N47_3Q00);
	// Init_SSD2828(init_ST7703_BV055HDE_47_IPS_Code);
	init();

	while (1) {
		/* USER CODE END WHILE */

		/* USER CODE BEGIN 3 */
		/*HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET);
		HAL_Delay(1000);
		HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_SET);
		HAL_Delay(1000);*/

		// uint8_t dat = 0xa5;
		// HAL_UART_Transmit(&huart1, &dat, 1, 100);
		// HAL_Delay(1000);

		// printf("hello stm32\r\n");
		// HAL_Delay(1000);

		/*HAL_GPIO_TogglePin(LCD_RST_GPIO_Port, LCD_RST_Pin);
		HAL_GPIO_TogglePin(LCD_CS_GPIO_Port, LCD_CS_Pin);
		HAL_GPIO_TogglePin(LCD_MOSI_GPIO_Port, LCD_MOSI_Pin);
		HAL_GPIO_TogglePin(LCD_SCK_GPIO_Port, LCD_SCK_Pin);
		HAL_Delay(1000);*/

		/*if(HAL_GPIO_ReadPin(LCD_MISO_GPIO_Port, LCD_MISO_Pin) ==
		GPIO_PIN_SET)
		{
		  HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_SET);
		} else {
		  HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET);
		}
		HAL_Delay(200);*/

		printf("Loop...\r\n");
		HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
		HAL_Delay(1000);
	}
	/* USER CODE END 3 */
}

/**
 * @brief System Clock Configuration
 * @retval None
 */
void SystemClock_Config(void)
{
	RCC_OscInitTypeDef RCC_OscInitStruct = {0};
	RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

	/** Initializes the CPU, AHB and APB busses clocks
	 */
	RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
	RCC_OscInitStruct.HSIState = RCC_HSI_ON;
	RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
	RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
	RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI_DIV2;
	RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL16;
	if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
		Error_Handler();
	}
	/** Initializes the CPU, AHB and APB busses clocks
	 */
	RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK |
				      RCC_CLOCKTYPE_SYSCLK |
				      RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
	RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
	RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
	RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
	RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

	if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) !=
	    HAL_OK) {
		Error_Handler();
	}
}

/**
 * @brief NVIC Configuration.
 * @retval None
 */
static void MX_NVIC_Init(void)
{
	/* USART1_IRQn interrupt configuration */
	HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
	HAL_NVIC_EnableIRQ(USART1_IRQn);
}

/**
 * @brief USART1 Initialization Function
 * @param None
 * @retval None
 */
static void MX_USART1_UART_Init(void)
{

	/* USER CODE BEGIN USART1_Init 0 */

	/* USER CODE END USART1_Init 0 */

	/* USER CODE BEGIN USART1_Init 1 */

	/* USER CODE END USART1_Init 1 */
	huart1.Instance = USART1;
	huart1.Init.BaudRate = 115200;
	huart1.Init.WordLength = UART_WORDLENGTH_8B;
	huart1.Init.StopBits = UART_STOPBITS_1;
	huart1.Init.Parity = UART_PARITY_NONE;
	huart1.Init.Mode = UART_MODE_TX_RX;
	huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
	huart1.Init.OverSampling = UART_OVERSAMPLING_16;
	if (HAL_UART_Init(&huart1) != HAL_OK) {
		Error_Handler();
	}
	/* USER CODE BEGIN USART1_Init 2 */

	/* USER CODE END USART1_Init 2 */
}

/**
 * @brief GPIO Initialization Function
 * @param None
 * @retval None
 */
static void MX_GPIO_Init(void)
{
	GPIO_InitTypeDef GPIO_InitStruct = {0};

	/* GPIO Ports Clock Enable */
	__HAL_RCC_GPIOC_CLK_ENABLE();
	__HAL_RCC_GPIOA_CLK_ENABLE();
	__HAL_RCC_GPIOB_CLK_ENABLE();

	/*Configure GPIO pin Output Level */
	HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET);

	/*Configure GPIO pin Output Level */
	HAL_GPIO_WritePin(GPIOA,
			  LCD_RST_Pin | LCD_CS_Pin | LCD_SCK_Pin | LCD_MOSI_Pin,
			  GPIO_PIN_RESET);

	/*Configure GPIO pin Output Level */
	HAL_GPIO_WritePin(GPIOB, SHUT_Pin | U_CON_Pin, GPIO_PIN_RESET);

	/*Configure GPIO pin : LED_Pin */
	GPIO_InitStruct.Pin = LED_Pin;
	GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
	GPIO_InitStruct.Pull = GPIO_NOPULL;
	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
	HAL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct);

	/*Configure GPIO pins : LCD_RST_Pin LCD_CS_Pin LCD_SCK_Pin LCD_MOSI_Pin
	 */
	GPIO_InitStruct.Pin =
	    LCD_RST_Pin | LCD_CS_Pin | LCD_SCK_Pin | LCD_MOSI_Pin;
	GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
	GPIO_InitStruct.Pull = GPIO_NOPULL;
	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
	HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

	/*Configure GPIO pin : LCD_MISO_Pin */
	GPIO_InitStruct.Pin = LCD_MISO_Pin;
	GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
	GPIO_InitStruct.Pull = GPIO_NOPULL;
	HAL_GPIO_Init(LCD_MISO_GPIO_Port, &GPIO_InitStruct);

	/*Configure GPIO pins : SHUT_Pin U_CON_Pin */
	GPIO_InitStruct.Pin = SHUT_Pin | U_CON_Pin;
	GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
	GPIO_InitStruct.Pull = GPIO_NOPULL;
	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
	HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
}

/* USER CODE BEGIN 4 */

/* USER CODE END 4 */

/**
 * @brief  This function is executed in case of error occurrence.
 * @retval None
 */
void Error_Handler(void)
{
	/* USER CODE BEGIN Error_Handler_Debug */
	/* User can add his own implementation to report the HAL error return
	 * state */

	/* USER CODE END Error_Handler_Debug */
}

#ifdef USE_FULL_ASSERT
/**
 * @brief  Reports the name of the source file and the source line number
 *         where the assert_param error has occurred.
 * @param  file: pointer to the source file name
 * @param  line: assert_param error line source number
 * @retval None
 */
void assert_failed(uint8_t *file, uint32_t line)
{
	/* USER CODE BEGIN 6 */
	/* User can add his own implementation to report the file name and line
	   number,
	   tex: printf("Wrong parameters value: file %s on line %d\r\n", file,
	   line) */
	/* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
